

<h1 align="center">Form starter code </h1>
Use this as a start code when you want to start creating new form. Will speed up the process! :)
{literal}
<pre class="code">
&lt;?php
	public function manageItem( $id = NULL ) {
				
		$new = $id == 0;
		$item = $new ? new Item() : Item::load($id);
			
		$post = DomFgPost::getInstance();
		
		if( $post-&gt;save ) {
			
			$item-&gt;name = $post-&gt;name;
			
			if( $item-&gt;save() ) {
				$id = $item-&gt;id;
				$message = array(
					'type' =&gt; 'ok',
					'colspan' =&gt; 2,
					'message' =&gt; 'Salvestatud',
				);
			} else {
				$message = array(
					'type' =&gt; 'ok',
					'colspan' =&gt; 2,
					'message' =&gt; 'Tekkinud on viga!',
					'description' =&gt; implode('&lt;br&gt;',$item-&gt;getValidationReport()-&gt;messages),
				);
			}
		}
		
		$panel = array(
			'title' =&gt; 'Item',
			'layout' =&gt; 'table',
			'action' =&gt; $this-&gt;getUrl('manageItem/'.$id),
			'layoutConfig' =&gt; array(
				'columns' =&gt; 2,
				'columnWidths' =&gt; array( 150 ),
			),
			'items' =&gt; array(
				$message ,
				array(
					'type' =&gt; 'textField',
					'title' =&gt; 'Nimi',
					'value' =&gt; $item-&gt;name,
					'name' =&gt; 'name',
				),
			),
			'buttons' =&gt; array(
				array(
					'title' =&gt; 'Salvesta',
					'name' =&gt; 'save'
				),
			),
		);
		
		$this-&gt;view-&gt;contents = DomFg::render( $panel );
	}
?&gt;
</pre>
{/literal}

